<template>
  <div class="layout-all">
    <control :config="config" />
    <div class="layout-header" style="float: left;"></div>
    <div class="layout-content">
      <el-table
        :data="tableData"
        stripe
        align="center"
        highlight-current-row
        style="width: 100%; margin-top: 50px;"
      >
      <el-table-column align="center" prop="id" label="序号" width="70" :fixed="isMobile()?'left':undefined"/>
        <el-table-column align="center" prop="remark" label="备注" />
        <el-table-column align="center" prop="money" label="金额" width="150" />
        <el-table-column align="center" prop="level" label="等级" width="150" />
        <el-table-column
          align="center"
          prop="status"
          label="状态"
          width="80"
        >
          <template slot-scope="scope">
            <el-tag
              v-if="scope.row.status === 0"
              type="warning"
              disable-transitions
              >预分润</el-tag
            >
            <el-tag
              v-if="scope.row.status === 1"
              type="info"
              disable-transitions
              >待分润</el-tag
            >
            <el-tag
              v-if="scope.row.status === 2"
              type="primary"
              disable-transitions
              >已分润</el-tag
            >
            <el-tag
              v-if="scope.row.status === 3"
              type="success"
              disable-transitions
              >已完成</el-tag
            >
          </template>
        </el-table-column>
        <el-table-column align="center" prop="user" label="用户">
          <template slot-scope="scope">
            <el-tag type="success" disable-transitions>{{
              scope.row.user === null ? "无" : scope.row.user.nickname
            }}</el-tag>
          </template>
        </el-table-column>

        <el-table-column align="center" prop="trigger_user" label="下级用户">
          <template slot-scope="scope">
            <el-tag type="success" disable-transitions>{{
              scope.row.trigger_user === null
                ? "无"
                : scope.row.trigger_user.nickname
            }}</el-tag>
          </template>
        </el-table-column>

        <!-- <el-table-column align="center" prop="status" label="是否启用" width="80">
          <template slot-scope="scope">
            <el-button
              :type="scope.row.status === 1 ? 'primary' : 'success'"
              size="mini"
              @click="change_status(scope.row.id,'status' ,scope.row.status)"
            >{{ scope.row.status === 1 ? "是" : "否" }}</el-button>
          </template>
        </el-table-column> -->
      </el-table>
    </div>
    <el-pagination
      :current-page="current_page"
      :page-size="per_page"
     layout="total, prev, pager, next, jumper"
      :total="total"
      @size-change="handleSizeChange"
      @current-change="handleCurrentChange"
    />
  </div>
</template>

<script>
import control from "../../components/control/control";
export default {
  components: { control },
  data() {
    return {
      config: [
        { type: "text", placeholder: "请输入备注", field: "remark", val: "" },
      ],
      value: "",
      searchWhere: {
        title: "",
      },
      tableData: [],
      total: 0,
      current_page: 1,
      per_page: 14,
    };
  },
  mounted() {
    this.onSearch();
  },
  methods: {
    // 查询
    handleSizeChange(val) {
      this.onSearch();
    },
    handleCurrentChange(val) {
      this.current_page = val;
      this.onSearch();
    },
    onSearch() {
      const form = {};
      form.page = this.current_page;
      form.map = this.searchWhere;
      this.get("/admin/CommunityTeamLogs/index", form, "POST").then((e) => {
        this.tableData = e.list.data;
        this.per_page = e.list.per_page;
        this.total = e.list.total;
        this.current_page = e.list.current_page;
      });
    },
    // 添加
    onAdd() {},
    // 编辑
    onEdit(id) {
      console.log(id);
    },
    // 修改状态
    change_status(id, field, val) {
      this.update(id, val, field, "CommunityTeamLogs").then((e) => {
        e ? this.onSearch() : "";
      });
    },
    // 删除
    // onDel(id) {
    //   this.$msg_confirm.then(e => {
    //     if (e) {
    //       this.get('/admin/Team/del?id=' + id, this.form, 'POST').then(e => {
    //         this.onSearch()
    //       })
    //     }
    //   })
    // }
  },
};
</script>

<style>
.layout-all {
  margin-top: 20px;
  margin-left: 10px;
}
.layout-content {
  margin-top: 20px;
}
</style>>
